<template>
  <div>
    <h2>轮询</h2>
    <div>
      <button @click="start">start1</button>
      <button @click="start">start2</button>
      <button @click="start">start3</button>
    </div>
    <div>
      <button @click="stop">stop</button>
    </div>
  </div>
</template>

<script>
import Polling from "./src/polling";

function getMessage() {
  return new Promise((resolve) => {
    setTimeout(() => {
      resolve("result");
    }, 2000);
  });
}
const poll = new Polling(
  getMessage,
  (ret) => {
    console.log(ret);
  },
  1000
);
export default {
  name: "polling",
  data: () => ({}),
  computed: {},
  watch: {},
  methods: {
    start() {
      poll.start();
    },
    stop() {
      poll.stop();
    }
  }
};
</script>

<style scoped></style>
